library(foreign)
library(ggplot2)
validation<-read.dta(file="Fig-data_figure2.dta")

library(plyr)
	validation2<-subset(validation,year==1972|  year==1976 | year==1980 | year==1984 | year==1988 | year==1992 | year==1996 | year==2000 | year==2004 | year==2008 | year==2012)
validation2<-as.data.frame(validation2)
cors <- ddply(validation2,c("year"),  summarise, cor = round(cor(govislib, president_share, use="complete.obs"), 2))

	pdf(file="Fig-figure2.pdf", width=12, height=7.5)
    print(ggplot(data=validation2, aes(x=govislib, y=president_share, label=abb))
               + geom_text(size=2)
     #+ geom_point()
          + theme(axis.title.x=element_text(size=14))
		  + theme(axis.title.y=element_text(size=14))
		   + geom_smooth(method="lm", se=FALSE, colour="black")
          + facet_wrap(~year, ncol=4)
        + ylab("Democratic Presidential Vote")
        + xlab("Policy Liberalism")
        +theme(plot.title=element_text(size=20))
 		+ geom_text(data=cors, aes(label=paste("r=", cor, sep="")), size=4,x=-.2, y=.75)
 		        + theme_bw()
)
    dev.off()
